package com.jacky.javafx.utils;


import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects;

public class DateTimeUtil {

    private static final String DEFAULT_FORMAT_STR = "yyyy-MM-dd HH:mm:ss";
    private static final String DEFAULT_FORMAT_MS_STR = "yyyy-MM-dd HH:mm:ss.SSS";
    private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormatter.ofPattern(DEFAULT_FORMAT_STR);
    private static final DateTimeFormatter DEFAULT_MS_FORMATTER = DateTimeFormatter.ofPattern(DEFAULT_FORMAT_MS_STR);

    public static String defaultFormat(LocalDateTime ldt) {
        return Objects.isNull(ldt) ? "" : DEFAULT_FORMATTER.format(ldt);
    }
}
